/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = t_ora_analyze_header.c                            */
/*  NOTE      =                                                    */
/*  DATE      = 2016/03/10 by songbb                               */
/*******************************************************************/

#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"

#include "../../../../src/module/oracle/config.h"
#include <oracle/ora_core.h>
#include <oracle/comm/ora_comm.h>
#include <oracle/tns/ora_packet.h>
#include <apmtest_comm.h>

static int __suite_init(void)
{
    return 0;
}

static int __suite_cleanup(void)
{
    return 0;
}

/**
 * 正常测试
 */
static void __case1(void)
{
    char *p_bin = (char *) "00e7000001000000013b012c0c412000ffff4f980000000100a10046000000008181000000000000000000000000000000000000000000000000000020000020000000000000284445534352495054494f4e3d28414444524553533d2850524f544f434f4c3d5443502928484f53543d3137322e31362e302e37372928504f52543d31353231292928434f4e4e4543545f444154413d284349443d2850524f4752414d3d4a444243205468696e20436c69656e742928484f53543d5f5f6a6462635f5f2928555345523d57696e292928534552564943455f4e414d453d7064626f72636c292929";
    char arr_payload[65536] = {'\0'};
    int i_large_sdu_flag = 0;

    CU_ASSERT_EQUAL(apmtest_hex_string_to_bin(p_bin, arr_payload, sizeof(arr_payload)), FR_SUCC);

    CU_ASSERT_EQUAL(ora_header_detect(arr_payload, strlen(p_bin) / 2, &i_large_sdu_flag), APM_L7_IS_YES);
}

int add_suite_ora_header_detect(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite(MODULE_NAME" ora_header_detect()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    if (CU_add_test(pSuite, "case1", __case1) == NULL)
        return FR_FAIL;

    return FR_SUCC;
}
